import tensorflow.compat.v1 as tf

input01 = tf.constant([
    [[2, 4, 5, 9],
     [3, 7, 6, 8],
     [4, 2, 5, 6],
     [6, 3, 2, 4]]
])
input01 = tf.expand_dims(input01, -1)  # ATTENTION
result01 = tf.nn.max_pool(input01,
                          ksize=[1, 2, 2, 1],
                          strides=[1, 2, 2, 1],
                          padding='VALID')

input02 = tf.constant([
    [[1, 3, 2, 1, 3],
     [2, 9, 1, 1, 5],
     [1, 3, 2, 3, 2],
     [8, 3, 5, 1, 0],
     [5, 6, 1, 2, 9]]
])
input02 = tf.expand_dims(input02, -1)
result02 = tf.nn.max_pool(input02,
                          ksize=[1, 3, 3, 1],
                          strides=[1, 1, 1, 1],
                          padding='VALID')

a = tf.constant([
    [
        [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 8]],
        [[8, 7, 6], [6, 5, 4], [4, 3, 2], [2, 1, 1]],
        [[4, 3, 2], [2, 1, 4], [8, 7, 6], [6, 5, 5]],
        [[1, 2, 3], [3, 4, 1], [5, 6, 7], [7, 8, 8]]
     ]
])
pooling = tf.nn.max_pool(a, [1, 2, 2, 1], [1, 2, 2, 1], padding='VALID')
with tf.Session() as sess:
    print('result01')
    print(sess.run(result01))

    print('result02')
    print(sess.run(result02))

    print("image:")
    image = sess.run(a)
    print(image.shape)
    print(image)
    print("result:")
    result = sess.run(pooling)
    print (result.shape)
    print (result)
